/**
 * 获取系统信息，包括状态栏和导航栏高度
 * @returns {Object} 返回包含各种高度信息的对象
 */
export const getSystemInfo = () => {
  try {
    const sysInfo = uni.getSystemInfoSync()
    const statusBarHeight = sysInfo.statusBarHeight
    const defaultNavBarHeight = 44 // 默认导航栏高度
    
    let navBarHeight = defaultNavBarHeight
    let menuButtonRect = null
    let totalHeight = statusBarHeight + defaultNavBarHeight

    // #ifndef APP || H5
    if (uni.canIUse('getMenuButtonBoundingClientRect')) {
      menuButtonRect = uni.getMenuButtonBoundingClientRect()
      // 计算导航栏高度
      navBarHeight = (menuButtonRect.top - statusBarHeight) * 2 + menuButtonRect.height
      // 计算总高度
      totalHeight = statusBarHeight + navBarHeight
    }
    // #endif

    return {
      statusBarHeight,    // 状态栏高度
      navBarHeight,      // 导航栏高度
      menuButtonRect,    // 胶囊按钮位置信息
      totalHeight,       // 总高度
      windowHeight: sysInfo.windowHeight,  // 窗口高度
      screenHeight: sysInfo.screenHeight   // 屏幕高度
    }
  } catch (e) {
    console.error('获取系统信息失败:', e)
    return {
      statusBarHeight: 20,
      navBarHeight: 44,
      totalHeight: 64,
      windowHeight: 0,
      screenHeight: 0
    }
  }
} 